Serializing a form into a JSON object[JavaScript] View PlainCopyPrint?
jquery.prototype.serializeobject= function (){
var obj= New Object ();
$.each (this. Serializearray (),function(index,param) {
if (!( Param.name in obj) {
Reprinted from: http://blog.csdn.net/zqtsx/article/details/28655717Original form form value acquisition method (manual):[JavaScript]View PlainCopy
$.ajax ({
Type: "POST",
URL: "ajax.php",
Data: "name= the star &position=it
The current situation is that the backend uses the PHP Yii framework to return the data to the front end in view mode.
There is a form form that, by binding the OnClick event, requests the data fetched by PHP to another backend, the following
The current situation is that the back-end uses the php yii framework to return data to the front-end in view mode. There is a form that binds the onclick event and sends the data requests obtained by php to another backend, that is, the following
. SerializeArray (); returns an Array
Description:Compile the value of the form Element Used for submission into an array consisting of name and value objects. For example, [{name: a value: 1}, {name: B value: 2},...], this method does not accept
APIS commonly used in JQuery Ajax operations: Differences and usage of serializeArray, serialize, And param, jqueryui
When using JQuery for ajax encoding, these three APIs are often used. This article describes how to use these three APIs. The
. Serializearray () serializes table elements (similar to the '. serialize ()' method) and returns JSONData structure data. (From the jquery document ).
There is a form window,Code:
Width = "100%" cellspacing = "0" cellpadding = "0"Border = "0">
In JavaScript, the Serialize () method also acts on a jquery object, which serializes the contents of the DOM element into a string, the Serializearray () method is not the return string, but instead serializes the DOM element. Returns data in JSON
. SerializeArray () serializes table elements (similar to the '. serialize ()' method) and returns JSON data structure data. (From the jquery document ).
There is a form window with the code:
Copy codeThe Code is as follows:
name:
mobile
The. Serializearray () serializes the table element (similar to the '. Serialize () ' method) to return the JSON data structure. (Excerpt from the jquery document).
There is one of the following form windows, code:
Copy Code code as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.